<template>
	<view class="">
		<!-- 实名认证 -->
		<u-popup :show="showdd" mode="top" @close="close">
			<view style="height: 100vh;background: url('https://laizuji.rchz.top/image/renlianImg.png');background-size: 100%;background-repeat: no-repeat;">
				<view class="wrap">
					<h2 class="xbsmrz">实名认证</h2>
					<h4 class="xbsmrz2">更加真实，更加可靠</h4>
					<view class="bs_xx">
						<view class="aaa">
							请您使用有本人身份证信息认证
						</view>
						<view class="sfxx">
							<view class="sfxx3">
								<view class="sfxx4s" >
									<view style="font-size: 30rpx;margin: 10rpx 0;margin-left: 30rpx;width:120rpx">
										姓名
									</view>
									<input placeholder="您的姓名" class="bor" v-model="value1"></u--input>
								</view>
					
								<view class="sfxx4s">
									<view style="font-size: 30rpx;margin: 10rpx 0;margin-left: 30rpx;width:120rpx">
										证件号
									</view>
									<input class="bor" placeholder="您的身份证号"  v-model="value2"></u--input>
								</view>
							</view>
						</view>
						<view class="anniu">
							<button style="border-radius: 44rpx;background-color: #417fff;color:white" @click="queding()">立即认证</button>
						</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default{
		props:['ids'],
		data(){
			return {
				value1: "",
				value2: "",
				showdd: false,
			}
		},
		methods:{
			close() {
				this.showdd = false;
			},
			queding() {
				let self = this;
				// console.log(self.value1, self.value2);
				if (uni.$u.test.idCard(self.value2) == false) {
					uni.showToast({
						title: '身份证号码有误,请重填！',
						duration: 2000,
						icon: 'none'
					});
					return;
				}
			
				if (self.value1 == '') {
					uni.showToast({
						title: '姓名不能为空！',
						duration: 2000,
						icon: 'none'
					});
					return;
				}
				self._post(
					'user.user/realNameAuthentication', {
						username: self.value1,
						usernum: self.value2
					},
					function(res) {
						// let type = uni.getSystemInfoSync()
						// self._post('/aiqian.Aiqian/face', {
						// 	usernam: self.value1,
						// 	idcard: self.value2,
						// 	order_id: self.ids
						// }, res1 => {
						// 	let data = Math.random(100)
						// 	let url = res1.data.data.faceUrl;
						// 	if (type.osName == 'ios') {
						// 		window.location.href = url;
						// 	} else {
						// 		window.open(url, data, '_self')
						// 	}
						// }, err => {
						// 	self.err = err
						// })
						
						//支付宝人脸
						self._post('order.order/faceAuthentication', {
							order_id: self.ids,
							name: self.value1,
							idno: self.value2
						}, (res) => {
							my.startAPVerify({
								url: res.data.url,
								success: (res) => {
									self._post('order.order/renzheng', {
										'order_id': self.ids,
										'states': res.resultStatus == '9000' ? 1 : 0
									}, (res) => {})
									self._post('order.order/faceStates', {
										"states": res.resultStatus == '9000' ? 1 : 0
									}, (res) => {})
									uni.navigateTo({
										url: '/pages/order/order-detail?order_id=' +
											self.ids
									})
								},
								fail: (err) => my.alert({
									title: 'openURL fail: ' + JSON
										.stringify(err)
								})
							})
						})
					})
			},
		}
	}
</script>

<style lang="scss">
	.bor{
		background: #eef0f2;
	}
	.sfxx4s{
		display: flex;
		margin: 28rpx 20rpx;
		border-radius: 21px;
		background: #eef0f2;
		padding: 5px;
	}
	.xbsmrz{
		position: relative;
		left: 30rpx;
		top: 228rpx;
		font-size: 44rpx;
		font-weight: bold;
		color: white;
	}
	.xbsmrz2{
		position: relative;
		top: 260rpx;
		left: 30rpx;
		color: white;
		width: 80%;
	}
	.animation-shake {
		animation: shake 2s !important;
	}
	
	.anniu {
		margin-top: 10rpx;
		width: 85%;
		border-radius: 50rpx;
	}
	
	.animation-shake {
		animation: shake 2s !important;
	}
	.bs_xx {
		height: 700rpx;
		padding: 10rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 300rpx;
		.aaa{
			    height: 55px;
			    width: 91.5%;
			    background-color: #e8ecf6;
			    text-align: center;
			    align-items: center;
			    line-height: 55px;
			    font-weight: bold;
			    font-size: 15px;
			    color: #494a4d;
					border-top-left-radius: 15px;
					border-top-right-radius: 15px;
		}
		.sfxx {
			width: 90%;
			padding: 30rpx 6rpx;
			background-color: #FFFFFF;
			.sfxx2 {
				padding: 20rpx 20rpx;
	
				view {
					color: #43A3E8;
					margin-top: 10rpx;
				}
			}
		}
	
		.anniu {
			margin-top: -10rpx;
			width: 85%;
			border-radius: 50rpx;
		}
	}
</style>